﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chess
{
    public class Program
    {
        public static char[,] board = new char[8, 8];

        public static void Main(string[] args)
        {

            SetUpBoard();

            String line;
            PrintBoard();

            while(!(line = Console.ReadLine()).Equals('q'))
            {
                string[] moves = line.Split(' ');
                Move(moves[0], moves[1]);

                PrintBoard();
            }


            Console.ReadKey();
        }

        public static void Move(string s, string e)
        {
            var i1 = GetIndex(s); 
            var i2 = GetIndex(e);
            board[i2.Item1, i2.Item2] = board[i1.Item1, i1.Item2];
            board[i1.Item1, i1.Item2] = '-';
        }

        public static void PrintBoard()
        {
            Console.Write("   ");
            for (int i = 1; i < 9; i++)
            {
                Console.Write(i + "  ");
            }
            Console.WriteLine();

            
            for (int x = 0; x < 8; x++)
            {
                Console.Write((char)(x + 97) + "  ");
                for (int j = 0; j < 8; j++)
                {
                    Console.Write(board[j, x] + "  ");
                }
                Console.WriteLine();
            }
            
        }


        public static void SetUpBoard()
        {
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    board[x, y] = '-';
                }
            }

            board[0, 0] = 'R';
            board[7, 0] = 'R';
            board[0, 7] = 'R';
            board[7, 7] = 'R';

            board[1, 0] = 'H';
            board[6, 0] = 'H';
            board[1, 7] = 'H';
            board[6, 7] = 'H';

            board[2, 0] = 'B';
            board[5, 0] = 'B';
            board[2, 7] = 'B';
            board[5, 7] = 'B';

            board[3, 0] = 'Q';
            board[3, 7] = 'Q';

            board[4, 0] = 'K';
            board[4, 7] = 'K';

            for (int i = 0; i < 8; i++)
            {
                board[i, 1] = 'P';
                board[i, 6] = 'P';
            }
        }

        public static Tuple<int, int> GetIndex(string pos)
        {
            int i1 = 0;
            switch (pos[0])
            {
                case 'a':
                    i1 = 0;
                    break;
                case 'b':
                    i1 = 1;
                    break;
                case 'c':
                    i1 = 2;
                    break;
                case 'd':
                    i1 = 3;
                    break;
                case 'e':
                    i1 = 4;
                    break;
                case 'f':
                    i1 = 5;
                    break;
                case 'g':
                    i1 = 6;
                    break;
                case 'h':
                    i1 = 7;
                    break;

            }

            int i2 = Int32.Parse(pos[1].ToString()) - 1;
            
           

            return new Tuple<int, int>(i2, i1);
        }

        public static string GetPos(Tuple<int, int> index)
        {
            return (char)(index.Item1 + 97) + (index.Item2 + 1).ToString();
        }
    }
}
